package com.neuedu.javase.methods;

/***
 * 项目名称:  MyJavaSE 
 * 包：  com.neuedu.javase.methods 
 * date:   2025/10/23   10:56  
 * 描述:  数学运算
 *  @author : 张金山
 *  作者博客:   https://blog.fulfill.com.cn
 */
public class Math {

    /**
     * 加和预算
     * @param numa int
     * @param numb int
     * @return
     */
    public static double  sum(int numa,  int numb ){
        return numa+numb;
    }


    /**
     * 方法的重载
     * @param numa
     * @param numb
     * @return
     */
    public static double  sum(double numa,  double numb ){
        return numa+numb;
    }


    /**
     * 方法的重载
     * @param numa
     * @param numb
     * @param otherNum  剩余参数
     * @return
     */
    public static double  sum(double numa,  double numb ,double... otherNum){
        double result =  numa + numb;
        if(otherNum != null){
            for (int i = 0; i < otherNum.length; i++) {
                result +=  otherNum[i];
            }
        }

        return result;
    }





    public static void main(String[] args) {
        //调用方法
        double result1 = sum(100,200);
        System.out.println(result1);


        double result2 = sum(100.0,200.0);
        System.out.println(result2);

        double result3 = sum(100.0,200.0,300.0);



        double result5 = sum(100.0,200.0,new double[]{300.0,400.0,500.0});
        //简写成下面的写法
        double result4 = sum(100.0,200.0,300.0,400.0,500.0);

        String.format("a 是%d  b是%d ",10,20);



    }


}
